﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace SpriteBuilder
{
    public partial class MainFrameForm : Form
    {

        Game1 Editor;

        public MainFrameForm()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);

        }

        public void SetEditor(Game1 editor)
        {
            Editor = editor;
            editor.EditorForm = this;

        }

        void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            Editor.Exit();
        }

        public IntPtr getDrawSurface { get { return MainFrame.Handle; } set { ;} }

        private void beendenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
            Application.Exit();
        }

        private void MainFrameForm_Load(object sender, EventArgs e)
        {

        }

        private void beendenToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void splitContainer1_Panel1_Resize(object sender, EventArgs e)
        {
            int height = splitContainer1.Panel1.Height;
            int width = splitContainer1.Panel1.Width;

            if (Editor != null)
                Editor.rezise(width, height);
        }

        private void neuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();
            
            switch (result)
            {
                case DialogResult.Abort:
                    break;
                case DialogResult.Cancel:
                    break;
                case DialogResult.Ignore:
                    break;
                case DialogResult.No:
                    break;
                case DialogResult.None:
                    break;
                case DialogResult.OK:
                    for (int i = 0; i < openFileDialog1.FileNames.Length; i++)
                    {
                        Editor.loadFrame(File.OpenRead(openFileDialog1.FileNames[i]));
                    }
                    break;
                case DialogResult.Retry:
                    break;
                case DialogResult.Yes:
                    break;
                default:
                    break;
            }
        }

        internal void setPropGrid(EditorTextureElement FrameAuswahl)
        {
            propertyGrid1.SelectedObject = FrameAuswahl;
        }
    }
}
